
/**
 * Write a description of class Test here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */

import java.io.*;//IOException;
import java.net.*;//URLConnection;
import java.lang.*;
import java.security.*;
//import java.net.URL;
//import java.io.InputStreamReader;

public class Test
{
    // instance variables - replace the example below with your own

    static public void main(String[] args){

        String stringURL = "Carlos Henrique Santos da Rosa";  

        try{
            String strVendor = System.getProperty("java.vendor");
            String strVersion = System.getProperty("java.version");
            //Assumes a system version string of the form:
            //[major].[minor].[release]  (eg. 1.2.2)
            Double dVersion = new Double(strVersion.substring(0, 3));
            //If we are running in a MS environment, use the MS stream handler.
            if( -1 < strVendor.indexOf("Microsoft") )
            {
                try
                {
                    Class clsFactory = 
                        Class.forName("com.ms.net.wininet.WininetStreamHandlerFactory" );
                    if ( null != clsFactory )
                        URL.setURLStreamHandlerFactory(
                            (URLStreamHandlerFactory)clsFactory.newInstance());
                }
                catch( ClassNotFoundException cfe )
                {
                    throw new Exception("Unable to load the Microsoft SSL " +
                        "stream handler.  Check classpath."  +  cfe.toString());
                }
                //If the stream handler factory has 
                //already been successfully set
                //make sure our flag is set and eat the error
               
            }
            
            //If we are in a normal Java environment,
            //try to use the JSSE handler.
            //NOTE:  JSSE requires 1.2 or better
            else if( 1.2 <= dVersion.doubleValue() )
            {
                System.setProperty("java.protocol.handler.pkgs", 
                    "com.sun.net.ssl.internal.www.protocol"); 
                try
                {
                    //if we have the JSSE provider available, 
                    //and it has not already been
                    //set, add it as a new provide to the Security class.
                    Class clsFactory = Class.forName("com.sun.net.ssl.internal.ssl.Provider");
                    if( (null != clsFactory) && (null == Security.getProvider("SunJSSE")) )
                        Security.addProvider((Provider)clsFactory.newInstance());
                }
                catch( ClassNotFoundException cfe )
                {
                    throw new Exception("Unable to load the JSSE SSL stream handler." +  
                        "Check classpath."  + cfe.toString());
                }
            }
            /*            // Ler bits do arquivo
            File f = new File( "README.txt" );  
            byte[] b = new byte[9024];  
            int i = 0;
            String c = "";
            int bit = 0;
            FileInputStream fi = new FileInputStream(f);  
            while ((i=fi.read(b)) > -1) {  
            for (int j = 0; j < i; j++) {  
            System.out.print( b[j]); //& (7 << bit)
            c = c + b[j];
            bit = bit + b[j];
            if ( c.length()/11 == 1){
            //System.out.println("\n\n" + bit);
            bit = 0;
            }

            }  
            }  
            System.out.println(c.length()/6 + " - " + c.length()+ "\n\n" );

            System.out.println( t( c.substring(  0, 13) ) + "\n\n" );//29
            System.out.println( t( c.substring( 13, 26) ) + "\n\n" );//
            System.out.println( t( c.substring( 26, 39) ) + "\n\n" );
            System.out.println( t( c.substring( 39, 52) ) + "\n\n" );
            System.out.println( t( c.substring( 52, 65) ) + "\n\n" );
            System.out.println( t( c.substring( 65, 78) ) + "\n\n" );

            fi.close(); */
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    /**
     * Constructor for objects of class Test
     */
    public Test()
    {
        // initialise instance variables
    }

    public static String t(String str)
    {
        // initialise instance variables
        int i = 0;
        int soma = 0;
        while( i < str.length()){
            soma = soma + Integer.parseInt( str.substring(i,i+1) );
            i++;
        }
        //str = soma.toString();
        System.out.print("Soma: " + soma + " - ");
        return str;

    }
}
